<%!

	private static final int DETAILED = 5; // nr of minutes

	public static int parseHour(String uur)
	{
		String[] hour = uur.split("[h:u]");
		int r = 0;
		try {
			r = Integer.parseInt(hour[0])*12 + Integer.parseInt(hour[1])/5;
		}
		catch (Exception ex)
		{
			
		}
		return r;
	}

	public static java.lang.String getGraphicalTable(be.artesis.titamo.io.TimeTableEntry[] data)
	{
		java.lang.String table = "";
		
		int startuur = parseHour("8u00");
		int colspanhour = 60/DETAILED;
		
		
		table += "<TABLE class=\"timetable\">\n<TR>";
		for (int i = 8; i < 18; i++)
		{
			table+= "<TH COLSPAN=\"" + colspanhour + "\">" + i + "u</TH>";
		}
		table += "</TR>";
		int einduur = parseHour("18u00");
		int einduur_vorige = startuur;
		for (be.artesis.titamo.io.TimeTableEntry e : data)
		{
			
			int start = parseHour(e.getStart());
			if ((start - einduur_vorige) > 0) table += "<TD CLASS=\"free\" COLSPAN=\"" + (start - einduur_vorige) + "\"></TD>\n";
			int colspan = parseHour(e.getDuration());
			table += "<TD CLASS=\"notfree\" COLSPAN=\"" + colspan + "\">" 
				+ "<div class=\"start\">" + e.getStart() + "</div>"
				+ "<div class=\"course\">" + e.getCourse() + "</div>"
				+ "<div class=\"group\"><" + e.getGroup() + "></div>"
				+ "<div class=\"instructor\">" + e.getInstructor() + "</div>"
				+ "<div class=\"room\">" + e.getRoom() + "</div>"
				+ "</TD>\n";
			einduur_vorige = start + colspan;
		}
		if ((einduur - einduur_vorige) > 0) table += "<TD CLASS=\"free\" COLSPAN=\"" + (einduur - einduur_vorige) + "\"></TD>\n";
		table += "</TR>\n";	
		table += "</TABLE>";
		
		return table;
	}
	
%>